Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add more unit tests for add_to_list. #2531

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Jan 9, 2024

This change is Reviewable

toxcore/DHT_test.cc Outdated Show resolved Hide resolved
@iphydf iphydf force-pushed the add-to-list-test branch 3 times, most recently from 4f43c3b to a910f04 Compare January 10, 2024 00:11
@iphydf iphydf requested a review from a team as a code owner January 10, 2024 00:11
@iphydf iphydf force-pushed the add-to-list-test branch 5 times, most recently from 02ecdb9 to 9b2241e Compare January 10, 2024 00:26
@pull-request-attention pull-request-attention bot assigned Green-Sky and unassigned iphydf Jan 10, 2024
@iphydf iphydf force-pushed the add-to-list-test branch 2 times, most recently from c378cf2 to b4d7bf4 Compare January 10, 2024 00:38
@iphydf iphydf force-pushed the add-to-list-test branch 3 times, most recently from 5e56eba to c68aeac Compare January 10, 2024 00:52
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 58 lines in your changes are missing coverage. Please review.

Comparison is base (05ce5c1) 68.97% compared to head (afc38f2) 69.12%.

Files Patch % Lines
toxcore/DHT_test.cc 70.53% 33 Missing ⚠️
toxcore/crypto_core_test_util.cc 50.00% 11 Missing ⚠️
toxcore/network_test_util.cc 65.38% 9 Missing ⚠️
toxcore/DHT_test_util.cc 63.63% 4 Missing ⚠️
toxcore/test_util_test.cc 96.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2531      +/-   ##
==========================================
+ Coverage   68.97%   69.12%   +0.14%     
==========================================
  Files          89       96       +7     
  Lines       27784    27983     +199     
==========================================
+ Hits        19164    19343     +179     
- Misses       8620     8640      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iphydf iphydf force-pushed the add-to-list-test branch 2 times, most recently from 22db489 to 8d3f656 Compare January 10, 2024 01:03
@nurupo
Copy link
Member

nurupo commented Jan 10, 2024

toxcore/crypto_core_test_util.cc line 51 at r2 (raw file):

{
    Test_Random *self = static_cast<Test_Random *>(obj);
    return static_cast<uint32_t>(simple_rng(self->seed)) % upper_bound;

Nit: modulo doesn't result in a uniform distribution, it gets skewed. Might not matter for testing though.
C++' random library has random number generators andstd::uniform_int_distribution() too, wonder why they weren't used here.

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @Green-Sky and @nurupo)


toxcore/crypto_core_test_util.cc line 51 at r2 (raw file):

Previously, nurupo wrote…

Nit: modulo doesn't result in a uniform distribution, it gets skewed. Might not matter for testing though.
C++' random library has random number generators andstd::uniform_int_distribution() too, wonder why they weren't used here.

Added a comment. I'll test/benchmark the C++ stdlib stuff later. For now, this is a very simple and fast implementation intended to be exactly that.

Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @Green-Sky and @nurupo)


toxcore/crypto_core_test_util.cc line 51 at r2 (raw file):

Previously, iphydf wrote…

Added a comment. I'll test/benchmark the C++ stdlib stuff later. For now, this is a very simple and fast implementation intended to be exactly that.

I guess LCG is the same as I put above. Maybe I'll refactor it tomorrow, or otherwise it'll be done in the next round of refactorings.

@iphydf iphydf force-pushed the add-to-list-test branch 3 times, most recently from ea3a53c to 00c81fb Compare January 10, 2024 01:43
Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @Green-Sky and @nurupo)


toxcore/crypto_core_test_util.cc line 51 at r2 (raw file):

Previously, iphydf wrote…

I guess LCG is the same as I put above. Maybe I'll refactor it tomorrow, or otherwise it'll be done in the next round of refactorings.

I've decided to use C++ :P. Done.

@nurupo nurupo requested a review from Green-Sky January 10, 2024 01:59
Copy link
Member

@nurupo nurupo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r8, all commit messages.
Reviewable status: 0 of 1 approvals obtained (waiting on @Green-Sky)

@nurupo
Copy link
Member

nurupo commented Jan 10, 2024

FYI was just pointing out something I noticed while skimming through the PR, don't plan on seriously reviewing it so don't hold the PR waiting on my review approval.

@iphydf iphydf merged commit afc38f2 into TokTok:master Jan 10, 2024
55 checks passed
@iphydf iphydf deleted the add-to-list-test branch January 10, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants